home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue47 / OOPRules / Main.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-05-30  |  1.3 KB  |  64 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, frm2, inher;
  8.  
  9. type
  10.   TFormMain = class(TForm)
  11.     Button1: TButton;
  12.     Edit1: TEdit;
  13.     Button2: TButton;
  14.     Button3: TButton;
  15.     procedure Button1Click(Sender: TObject);
  16.     procedure Button2Click(Sender: TObject);
  17.     procedure FormCreate(Sender: TObject);
  18.     procedure Button3Click(Sender: TObject);
  19.   private
  20.     DialogBox: TFormDialog;
  21.   public
  22.     { Public declarations }
  23.   end;
  24.  
  25. var
  26.   FormMain: TFormMain;
  27.  
  28. implementation
  29.  
  30. {$R *.DFM}
  31.  
  32. procedure TFormMain.Button1Click(Sender: TObject);
  33. begin
  34.   // create only one instance
  35.   if not Assigned (DialogBox) then
  36.     DialogBox := TFormDialog.Create (Edit1.Text);
  37.   DialogBox.Show;
  38. end;
  39.  
  40. procedure TFormMain.Button2Click(Sender: TObject);
  41. begin
  42.   with TFormInherit.Create (Edit1.Text) do
  43.     Show;
  44. end;
  45.  
  46. procedure TFormMain.FormCreate(Sender: TObject);
  47. begin
  48.   Button1 := FindComponent ('Button1') as TButton;
  49.   Edit1 := FindComponent ('Edit1') as TEdit;
  50.   Button2 := FindComponent ('Button2') as TButton;
  51. end;
  52.  
  53. procedure TFormMain.Button3Click(Sender: TObject);
  54. begin
  55.   if Assigned (DialogBox) then
  56.     ShowMessage (DialogBox [0]);
  57. end;
  58.  
  59. initialization
  60.   RegisterClasses ([
  61.     TButton,
  62.     TEdit, TListBox]);
  63. end.
  64.